package com.ajaxw.dump;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class DumpIdx {
	public void dump2screen(String file) throws IOException {
		FileInputStream fis = new FileInputStream(file);
		BufferedInputStream bis = new BufferedInputStream(fis);
		DataInputStream dis = new DataInputStream(bis);

		int lstNum = dis.readInt();
		for (int i = 0; i < lstNum; i++) {
			int len = dis.readInt();

			for (int j = 0; j < len; j++) {
				dis.readInt();
			}

			System.out.println(len);
		}
		dis.close();
		System.out.println("total term number: " + lstNum);
	}

	public void dump2file(String ff, String f2) throws IOException {
		FileInputStream fis = new FileInputStream(ff);
		BufferedInputStream bis = new BufferedInputStream(fis);
		DataInputStream dis = new DataInputStream(bis);

		FileOutputStream fos = new FileOutputStream(f2);
		BufferedOutputStream bos = new BufferedOutputStream(fos);
		Writer dos = new OutputStreamWriter(bos);

		int lstNum = dis.readInt();
		for (int i = 0; i < lstNum; i++) {
			int len = dis.readInt();

			for (int j = 0; j < len; j++) {
				dis.readInt();
			}

			dos.write("" + len);
			dos.write("\n");
		}

		dis.close();
		dos.close();
	}
}
